﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/3/24 11:56:44
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;
using ueEngine.Biz.Inf.Entities.DBSupport;


namespace ueEngine.Biz.Inf.LogicEntity
{
    
    public class PositionModel : IAccessible<Position,PositionModel>
    {
        #region self
        public int Id { get; set; }

        /// <summary>
        /// 招募单id
        /// </summary>
        public int RecruitId { get; set; }

        /// <summary>
        /// 招募标题
        /// </summary>
        public string PositionName { get; set; }

        /// <summary>
        /// 需求人数
        /// </summary>
        public int Vacancy { get; set; }
        /// <summary>
        /// 职位类型
        /// </summary>
        public PositionType PositionType { get; set; }

        /// <summary>
        /// 预计支付最小薪资额（单位为元人民币）
        /// 薪资为 薪资额+薪资结算周期
        /// </summary>
        public decimal MinSalary { get; set; }

        /// <summary>
        /// 预计支付最大薪资额（单位为元人民币）
        /// 薪资为 薪资额+薪资结算周期
        /// </summary>
        public decimal MaxSalary { get; set; }

        /// <summary>
        /// 结算周期
        /// 160：小时 40：天 8：周 1：月
        /// </summary>
        public SalaryPeriod Period { get; set; }

        /// <summary>
        /// 性别要求 -1：不限 0：女 1：男
        /// </summary>
        public Gender Gender { get; set; }
        /// <summary>
        /// 学位要求
        /// </summary>
        public Degree Degree { get; set; }

        /// <summary>
        /// 职位描述
        /// </summary>
        public string PositionDescript { get; set; }
        /// <summary>
        /// 是否要求有经验
        /// </summary>
        public bool Experienced { get; set; }

        /// <summary>
        /// 浏览次数
        /// </summary>
        public int ScanTime { get; set; }

        /// <summary>
        /// 审核操作员
        /// </summary>
        public string OperatorName { get; set; }

        /// <summary>
        /// 是否已经提交托管，且托管审核通过
        /// </summary>
        public bool Trusteeship { get; set; }

        /// <summary>
        /// 是否已经被索引
        /// </summary>
        public bool IsIndex { get; set; }
        /// <summary>
        /// 职位级别
        /// </summary>
        public PositionPriority Priority { get; set; }
        /// <summary>
        /// 兼职级别
        /// </summary>
        public PositionLevel PositionLevel { get; set; }
        /// <summary>
        /// 认证级别
        /// </summary>
        public CertificationLevel CertificationLevel { get; set; }
        #endregion

        #region recruit
        /// <summary>
        /// 招募单
        /// </summary>
        public RecruitSheetModel RecruitSheet { get; set; }
        #endregion

        #region DepositCompany
        public DepositCompanyModel DepositCompany { get; set; }
        #endregion

        #region RequestSheet
        public int ItemCountOfRequestSheet { get; set; }
        /// <summary>
        /// 该职位下的所有求职单
        /// </summary>
        public ItemListBox<RequestSheetModel> RequestSheetes { get; set; }
        #endregion

        protected override void Covariant(Position dbModel)
        {
            this.Id = dbModel.Id;
            this.IsIndex = dbModel.IsIndex;
            this.MaxSalary = dbModel.MaxSalary;
            this.MinSalary = dbModel.MinSalary;
            this.OperatorName = dbModel.OperatorName;
            this.Period = (SalaryPeriod)dbModel.Period;
            this.RecruitId = dbModel.RecruitId;
            this.ScanTime = dbModel.ScanTime;
            this.Trusteeship = dbModel.Trusteeship;
            this.Vacancy = dbModel.Vacancy;
            this.Degree = (Degree)dbModel.Degree;
            this.Experienced = dbModel.Experienced;
            this.Gender = (Gender)dbModel.Gender;
            this.PositionDescript = dbModel.PositionDescript;
            this.PositionName = dbModel.PositionName;
            this.PositionType = (PositionType)dbModel.PositionType;
            this.Priority = (PositionPriority)dbModel.PositionPriority;
            this.PositionLevel = (PositionLevel)dbModel.PositionLevel;
        }
        protected override Position Inverter(PositionModel model)
        {
            return new Position()
            {
                Id = model.Id,
                IsIndex = model.IsIndex,
                MaxSalary = model.MaxSalary,
                MinSalary = model.MinSalary,
                OperatorName = model.OperatorName,
                Period = (int)model.Period,
                RecruitId = model.RecruitId,
                ScanTime = model.ScanTime,
                Trusteeship = model.Trusteeship,
                Vacancy = model.Vacancy,
                Degree = (int)model.Degree,
                Experienced = model.Experienced,
                Gender = (int)model.Gender,
                PositionDescript = model.PositionDescript,
                PositionName = model.PositionName,
                PositionType = (int)model.PositionType,
                PositionPriority = (int)model.Priority,
                PositionLevel = (int)model.PositionLevel
            };
        }
        //public override PositionModel Element(System.Linq.Expressions.Expression<Func<Position, bool>> where)
        //{
        //    Covariant(new Position().Get(where));
        //    return this;
        //}
        //public override List<TResult> Elements<TResult>(System.Linq.Expressions.Expression<Func<Position, bool>> where, System.Linq.Expressions.Expression<Func<Position, TResult>> select)
        //{
        //    using (Context ctx = new Context())
        //    {
        //        return ctx.Position.Where(where).Select(select).ToList();
        //    }
        //}
    }
}
